package com.entity;

import java.math.BigDecimal;

/**
 * 满减类促销
 * @author HeLiwei
 * 2023年9月4日
 */
public class DeductPromotion extends Promotion{

	public DeductPromotion() {}
	
	public DeductPromotion(BigDecimal minPrice, BigDecimal deductPrice) {
		super();
		this.minPrice = minPrice;
		this.deductPrice = deductPrice;
	}

	/**
	 * 优惠门槛
	 */
	private BigDecimal minPrice;
	
	/**
	 * 优惠金额
	 */
	private BigDecimal deductPrice;

	public BigDecimal getMinPrice() {
		return minPrice;
	}

	public void setMinPrice(BigDecimal minPrice) {
		this.minPrice = minPrice;
	}

	public BigDecimal getDeductPrice() {
		return deductPrice;
	}

	public void setDeductPrice(BigDecimal deductPrice) {
		this.deductPrice = deductPrice;
	}

	@Override
	public BigDecimal getDeductPrice(Order order) {
		if(order.getTotalPrice().compareTo(minPrice) >= 0) {
			System.out.println("条件满足：满"+minPrice+"减"+deductPrice);
			return deductPrice;
		}
		System.out.println("条件不满足：满"+minPrice+"优惠 不享受折扣");
		return BigDecimal.ZERO;
	}
}
